package org.apache.james.mime4j.message;

import java.io.IOException;
import java.io.InputStream;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.field.UnstructuredField;
import org.apache.james.mime4j.parser.MimeEntityConfig;
import org.apache.james.mime4j.parser.MimeStreamParser;

public class Message extends Entity
  implements Body
{
  public Message(InputStream paramInputStream)
    throws IOException
  {
    this(paramInputStream, null);
  }

  public Message(InputStream paramInputStream, MimeEntityConfig paramMimeEntityConfig)
    throws MimeException, IOException
  {
    MimeStreamParser localMimeStreamParser = new MimeStreamParser(paramMimeEntityConfig);
    localMimeStreamParser.setContentHandler(new MessageBuilder(this));
    localMimeStreamParser.parse(paramInputStream);
  }

  public UnstructuredField getSubject()
  {
    return ((UnstructuredField)getHeader().getField("Subject"));
  }
}